#include <stdio.h>
 #include <glob.h>

 int main(int argc, const char *argv[])
 {
     glob_t buf;
     int i;
     glob("/etc/*",GLOB_NOSORT, NULL, &buf);

     for(i=0; i < buf.gl_pathc; i++)
     {
         printf("result[%d]= %s \n", i, (buf.gl_pathv[i]));
     }
     printf("files count %ld \n",buf.gl_pathc);
     

    globfree(&buf);
     return 0;
 }